﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<QLPKWeb.Models.FormBean.DanhMucChungModel.NgoaiTeForm>" %>

<%@ Import Namespace="QLPKWeb.Models.LinQ.DanhMucChung" %>
<%@ Import Namespace="Webdiyer.WebControls.Mvc" %>
<%@ Import Namespace="DONGACS.DTO" %>
<%@ Import Namespace="System.Web.Mvc.Html" %>


<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <script type="text/javascript" language="javascript" src="<%= ResolveUrl("~/Content/Scripts/DanhMucChung/NgoaiTe.js") %>"></script>
    
    <script language="javascript" type="text/javascript">
        $(document).ready(function() {
            $("#NgoaiTeSearch").focus();
        });
        $(document).ready(function () {
            selectMenu("danhmucchung-NgoaiTe");
            $("#danhmucchung-NgoaiTe").parent().attr("class", "expanded");
        });
    </script>

    <form id="form" method="post" action="#">
    
    <input type="hidden" id="Id" name="Id" value="<%=Model.Id %>"/>
    <%=Html.Hidden("PageNumber", Model.PageNumber)%>

        <div class="box round first fullpage">
            <h2>Đơn vị tiền tệ</h2>
		
		 <div class="box round first grid" style="border: 1px solid #ddd ">
                      <h2>Danh sách đơn vị tiền tệ</h2>
            <table class="data display datatable">
                <tr>
                    <td colspan="2" class="first">
                        &nbsp;<b></b>
                    </td>
                    <td colspan="2" class="first" align="right">
                        <%--<%=Html.TextBox("NgoaiTeSearch", "", new { @size = 50, @onkeypress = "if (event.keyCode==13) { return DoSearch(); }" })%>
                        <img onclick="javascript:DoSearch();" style="vertical-align: middle; cursor:pointer" src="<%=ResolveUrl("~/Content/ImagesAdmin/search_icon.gif")%>"
                            alt="Tìm kiếm Nơi luu trữ" title="Tìm kiếm Nơi luu trữ"/>--%>
                    </td>
                </tr>
                <tr>
                    <td colspan="4">
                         
                        <table cellspacing="0" cellpadding="0" class="data display datatable">
                            <tr class="title">
                                <td style="border: 1px solid #ddd "class="first" width="20%" align="center">
                                    <strong>ID</strong>
                                </td>
                                <td style="border: 1px solid #ddd ">
                                    <strong>Đơn vị</strong>
                                </td>    
                                    <td style="border: 1px solid #ddd ">
                                    <strong>Tiền tệ</strong>
                                </td>    
                                                               
                            </tr>
                            <%--Danhd Muc Đơn vị List--%>

                            <%
                            IList<dm_LoaiNgoaiTe> NgoaiTeList = Model.NgoaiTePagedList;
                            foreach (dm_LoaiNgoaiTe item in NgoaiTeList)
                            {
                            %>
                            <tr class="item_row" onclick="javascript:highlight(this);EditNgoaiTeAjax(<%=item.Id%>);">
                                <td style="border: 1px solid #ddd "class="first" align="center">
                                    <%=item.Id%>
                                </td>
                                <td style="border: 1px solid #ddd "align="left">
                                    <%=item.Ten%>&nbsp;
                                </td>
                                <td style="border: 1px solid #ddd "align="left">
                                 <a onclick="jsonAjax('<%=item.Id %>')"> <img src="../../Content/img/add.png" width="24px" height="15px" />
                                 <% try
                                    {
                                    %> <%=item.dm_NgoaiTe_TiGias.Where(p=>p.IsActive==true).ElementAt(0).GiaTriTiGia %></a>
                                    <%}
                                    catch (Exception)
                                    {
                                        %>
                                        0
                                        <%
                                    } %>
                                
                                </td>
                            </tr>
                            <%}
                            %>
                            <tr class="border_bottom">
                                <td class="first" style="background: #DDDDDD">
                                </td>
                                <td class="last" colspan="7" align="right" style="background: #DDDDDD; padding-right: 10px">
                                     <%
                                         PagerOptions pagerOptions = new PagerOptions();
                                         QLPKWeb.BussinessDelegate.CommonDelegate.CommonDelegate CommonDelegate
                                             = new QLPKWeb.BussinessDelegate.CommonDelegate.CommonDelegate();
                                         CommonDelegate.ChangeTextPaging(pagerOptions, string.Empty);
                                     %>
                                    <div><%=Html.Pager(Model.NgoaiTePagedList,pagerOptions) %></div>
                                    <%=Html.Hidden("PageNumber", Model.PageNumber)%>
                                </td>
                            </tr>
                            <%--dã xóa--%>
                        </table>
                       
                    </td>
                </tr>
            </table>
             </div>
          
            
            <table class="data display datatable">
                    
                    <tr>
                        <td colspan="2">
                            <%--Thông Báo--%>
                            <%
                                if (!string.IsNullOrEmpty(Model.MessageCreateNgoaiTe))
                                {
                            %>
                            <div id="MessageCreateNgoaiTe" style="font-size: 12px; color: Blue; font-weight: bold">
                                <%=Model.MessageCreateNgoaiTe%></div>
                            <%
                                }
                            %>
                            <%
                                if (!string.IsNullOrEmpty(Model.MessageEditNgoaiTe))
                                {
                            %>
                            <div id="MessageEditNgoaiTe" style="font-size: 12px; color: Blue; font-weight: bold">
                                <%=Model.MessageEditNgoaiTe%></div>
                            <%
                                }
                            %>
                            <%--end--%>
                        </td>
                        <td align="right">
                            <input type="button"class="btn btn-grey" value="Tạo/Cập nhật" onclick="DoCreateOrEdit()" />
                            <input type="button"class="btn btn-grey" value="Tạo mới" onclick="javascript:DoNew();" />
                            <input type="button"class="btn btn-grey" value="Xóa" onclick="javascript:DoDelete();" />
                            <input type="button"class="btn btn-grey" value="Hủy thay đổi" onclick="javascript:DoReset();" />
                        </td>
                    </tr>
                    
                    
                    </table >
                    <table class="table_input">
                    <%--<tr>
                        <td>
                            ID :
                        </td>
                        <td>
                            <span id="showId" style="line-height:30px"><%=Model.Id %></span>
                        </td>
                    </tr>--%>
                    <tr>
                        <td style="width: 20%; vertical-align:middle;">
                            <b>Tên Đơn vị:</b>
                        </td>
                        <td>
                            <input type="text" size="70" value="<%=Model.TenNgoaiTe%>" id="TenNgoaiTe" name="TenNgoaiTe"/>
                            <div id="TenNgoaiTeMessage" class="red"></div>
                        </td>
                    </tr>
                    
                    <%--<tr>
                        <td colspan="4">&nbsp;</td>
                    </tr>
                    <tr>
                        <td colspan="4" align="right">
                            <input type="button" value="Tạo/Cập nhật" onclick="DoCreateOrEdit()" />
                            <input type="button" value="Tạo mới" onclick="javascript:DoNew();" />
                            <input type="button" value="Xóa" onclick="javascript:DoDelete();" />
                            <input type="button" value="Hủy thay đổi" onclick="javascript:DoReset();" />
                        </td>
                    </tr>--%>
                </table>
           
       <%-- </div>--%>
    </div>
    <%--<%Html.EndForm(); %>--%>

    </form>
    
     <div title="Information UnitPrice" id="box3">
        <div style="float: right; padding-right: 70px;" >
         <input  type="button" id="SaveConfigInformation"name="SaveConfigInformation"  value="Save" onclick="SaveNgoaiTeMonney()"/>  
         <input  type="button" id="SaveConfigInformationnew"name="SaveConfigInformation"  value="Reset New" onclick="DoNewMoney()"/>  
         <input type="button" id="Button1"name="SaveConfigInformation"  value="Close" onclick="CloseInf()"/> 
        </div>
        <input type="hidden" id="IdMonney" name="IdMonney" value="0"/>
        <table> <tr> <td style='border: 1px solid #ddd ;  '> Rate: </td><td style='border: 1px solid #ddd '><input type="text" name="Rate" id="Rate"/></td>
                   
                     </tr> 
      </table>
       <div> <div id="Raw"></div>  </div>
        </div>
        
           <script type="text/javascript" language="javascript">
            
               $(function () {
                   $("#box3").dialog({
                       autoOpen: false,
                       modal: true,
                       width: 700
                   });
               });
               function jsonAjax(Id) {
                   $("#box3").dialog("open");
                   var url = basePath + "DanhMucChung/NgoaiTeMonneyListByIdNameAjax/" + Id;
                   $.getJSON(url, null, function (data) {
                       document.getElementById("Raw").innerHTML = data;
                   });
               }
               function ActiveAjax(Id) {
                   var url = basePath + "DanhMucChung/Active/" + Id;
                   $.getJSON(url, null, function (data) {
                       document.getElementById("Raw").innerHTML = data;
                   });
               }
               function CloseInf() {
                   $("#box3").dialog("close");
               }
               function SaveNgoaiTeMonney() {

                   if ($("#IdMonney").val() == 0) {

                       var url = basePath + "DanhMucChung/SaveNgoaiTeMonney?Monney=" + $("#Rate").val() + "&&IdNgoaiTe=" + $("#IdNgoaiTe").val();
                   } else {
                       var url = basePath + "DanhMucChung/SaveUpdateNgoaiTeMonney?Id=" + $("#IdMonney").val() + "&&Monney=" + $("#Rate").val() + "&&IdNgoaiTe=" + $("#IdNgoaiTe").val();
                   }
                   $.getJSON(url, null, function (data) {
                       document.getElementById("Raw").innerHTML = data;
                   });
               }
               function EditNgoaiTeMonneyAjax(Id) {
                   var url = basePath + "DanhMucChung/NgoaiTeMonneyEditAjax/" + Id;
                   $.getJSON(url, null, function (data) {
                       $("#IdMonney").val(data[0]);
                       $("#Rate").val(data[1]);
                     

                       //                var DangVien = data.DangVien;
                       //                if (DangVien != true) {
                       //                    document.getElementById("DangVien").checked = false;
                       //                }
                       //                else {
                       //                    document.getElementById("DangVien").checked = true;
                       //                }
                   });
               }
               function DoNewMoney() {
                   $("#IdMonney").val(0);
                   $("#Rate").val(0);
               }
        
    </script>
</asp:Content>
